<?php

class CMySQL {

    var $Connection = null;
    var $AutoNumber;

    function Connect() {
        $this->Connection = mysql_connect("localhost", "root", "") or die("Không thể kết nối cơ sở dữ liệu . Vui lòng kiểm tra thông tin đăng nhập CSDL");
        mysql_select_db("wordpress", $this->Connection);
        mysql_query("set names 'utf8'");
    }

    function FetchRow($query) {
        return mysql_fetch_row($query);
    }

    function FetchArray($query) {
        return mysql_fetch_array($query);
    }

    function FetchNum($query) {
        return mysql_num_rows($query);
    }

    function getError() {
        return mysql_error($this->Connection);
    }

    function getNum($sql) {
        $result = $this->Query($sql);
        return mysql_num_rows($result);
    }

    function getAutoNumber() {
        return $this->AutoNumber;
    }

    function Query($sql) {
        $this->Connect();
        $result = mysql_query($sql, $this->Connection);

        $this->AutoNumber = mysql_insert_id($this->Connection);

        if (mysql_error($this->Connection) == null)
            mysql_close($this->Connection);

        return $result;
    }

}

?>
